<style lang="less">

</style>
<template>
    <div>
        <Drawer :closable="false" placement="right" v-model="drawerVisible" width="50%" :title="drawerTitle">
            <Row>
                <Col>
                <Card :shadow="false">
                    <Row>
                        <Form ref="form" :model="form" :label-width="90" style="position:relative">
                            <FormItem label="审核结果" prop="checkStatus" >
                                <RadioGroup v-model="form.checkStatus" >
                                    <Radio :label="1" :disabled="disabledSingle">通过</Radio>
                                    <Radio :label="0" :disabled="disabledSingle">拒绝</Radio>
                                </RadioGroup>
                            </FormItem>
                            <FormItem label="拒绝原因" prop="refuseCause">
                                <Input type="textarea" :readonly="disabledSingle" v-model="form.refuseCause" style="width:600px"/>
                            </FormItem>
                            <Form-item class="br" v-show="!disabledSingle">
                                <Button type="primary" :loading="submitLoading" @click="handelSubmit" style="width:80px">提交</Button>
                                <Button @click="handelCancel">取消</Button>
                            </Form-item>
                            <Spin size="large" fix v-if="loading"></Spin>
                        </Form>
                    </Row>
                </Card>
                </Col>
            </Row>
        </Drawer>
    </div>
</template>
<script>
    import {setScorecheck} from "@/api/bus";
    import uploadInput from "@/views/my-components/flyme/upload-input";
    // 表情包配置 自定义表情可在该js文件中统一修改
    import {sina} from "@/libs/emoji";
    export default {
        name: "certificate-drawer",
        components: {
            uploadInput
        },
        data() {
            return {
                disabledSingle: false,
                picVisible: false,
                loading: false, // 表单加载状态
                drawerTitle: "证书修改",
                drawerVisible: false,
                form: {
                    id: '',
                    checkStatus: 1,
                    refuseCause: "",
                    usercertificateId: ''
                },
                submitLoading: false, // 添加或编辑提交状态
            };
        },
        methods: {
            showDrawer(params) {
                this.form.id = params.id;
                this.form.checkStatus = params.checkStatus;
                this.form.usercertificateId = params.usercertificateId;
                if(this.form.checkStatus === 2){
                    this.form.checkStatus = 1;
                    this.disabledSingle = false
                }else{
                    this.disabledSingle = true
                }
                this.drawerVisible = true;
            },
            handelSubmit() {
                this.$refs.form.validate(valid => {
                    if (valid) {
                        this.submitLoading = true;
                        // 编辑
                        setScorecheck(this.form).then(res => {
                            this.submitLoading = false;
                            if (res.status === true) {
                                this.$Message.success("操作成功");
                                this.$parent.getDataList();
                                this.drawerVisible = false;
                            }
                        });
                    }
                });
            },
            handelCancel() {
                this.drawerVisible = false;
            }
        },
        mounted() {

        },
        watch: {

        }
    };
</script>